package com.moofw.example.service.twitterScraper.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.social.oauth2.OAuth2Operations;
import org.springframework.social.twitter.api.Twitter;
import org.springframework.social.twitter.api.impl.TwitterTemplate;

@Configuration
@ImportResource("integration.xml")
@PropertySource("classpath:oauth.properties")
public class ServiceConfiguration {
	@Autowired
	private Environment env;

	@Bean
	public String newline() {
		return System.getProperty("line.separator");
	}

	@Bean
	public Twitter twitterTemplate() {
		return new TwitterTemplate(
				env.getRequiredProperty("twitter.oauth.consumerKey"),
				env.getRequiredProperty("twitter.oauth.consumerSecret"),
				env.getRequiredProperty("twitter.oauth.accessToken"),
				env.getRequiredProperty("twitter.oauth.accessTokenSecret"));
	}

}
